extends Node

export var max_health = 1 setget set_max_health
var health = max_health setget set_health

signal no_health
signal health_change(val)
signal max_health_change(val)

func set_max_health(val):
	max_health = val
	self.health = min(health,max_health)
	emit_signal("max_health_change",max_health)
	
func set_health(val):
	health = val
	emit_signal("health_change" , health)
	if health <= 0:
		emit_signal("no_health")

func _ready():
	self.health = max_health
